package com.example.helloworld

import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.TextView
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main)
        val linearLayout = LinearLayout(this)
        linearLayout.orientation = LinearLayout.VERTICAL
        val textView = TextView(this)
        textView.text = getString(R.string.hello)
        val imageView = ImageView(this)
        imageView.setImageResource(R.drawable.flag)
        val button = Button(this)
        button.text = getString(R.string.click_me)

        ViewCompat.setOnApplyWindowInsetsListener(linearLayout){v, insets ->
            val systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars())
            v.setPadding(systemBars.left, systemBars.top, systemBars.right,systemBars.bottom)
            insets
        }
        button.setOnClickListener {
            val textView = findViewById<TextView>(R.id.textView)
            textView.text = getString(R.string.i_am_clicked)
        }
    }
}